//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  IMessageSender.cs
//    
// Abstract:
//
//  This interface represents any channel that enhanced reminders can be delivered to.
//  
//--

using System;

namespace Microsoft.EnhancedReminders.Dispatcher
{
    /// <summary>
    /// Represents a strategy for delivering an Enhanced Reminder.
    /// </summary>
    public interface IMessageSender
    {
        /// <summary>
        /// Event that is fired when an attempt to deliver a notification completes.
        /// </summary>
        event EventHandler<DeliveryCompletedEventArgs> DeliverMessageCompleted;

        /// <summary>
        /// Delivers a notification asynchronously
        /// </summary>
        void DeliverMessageAsync();
    }

    /// <summary>
    /// Event args used for events that represent a completed
    /// delivery of a notification.
    /// </summary>
    public class DeliveryCompletedEventArgs : EventArgs
    {
        private NotificationResult _result;

        /// <summary>
        /// ctor.
        /// </summary>
        /// <param name="result">Indicates the result of the notification attempt</param>
        public DeliveryCompletedEventArgs(NotificationResult result)
        {
            _result = result;
        }

        /// <summary>
        /// Indicates the result of the notification attempt
        /// </summary>
        public NotificationResult Result
        {
            get
            {
                return _result;
            }
        }
    }

    /// <summary>
    /// Attribute describing whether or not a IMessageSender should be considered a "stop point."
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public sealed class StopPointAttribute : Attribute
    {
        private bool _isStopPoint;

        /// <summary>
        /// ctor.
        /// </summary>
        public StopPointAttribute(bool isStopPoint)
        {
            _isStopPoint = isStopPoint;
        }

        /// <summary>
        /// Whether or not a channel should be treated as a "stop point."
        /// </summary>
        public bool IsStopPoint
        {
            get
            {
                return _isStopPoint;
            }
        }
    }
}
